---
title: "Sandbox"
description: "Sandbox API Documentation"
icon: "code"
github: "https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/connectors/sandbox.py"
---

import {RandomGradientBackground} from "/snippets/gradient.jsx"

<Callout type="info" title="Source Code">
View the source code for this module on GitHub: <a href='https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/connectors/sandbox.py' target='_blank' rel='noopener noreferrer'>https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/connectors/sandbox.py</a>
</Callout>

## SandboxConnector

<div>
<RandomGradientBackground className="rounded-lg p-4 w-full h-full rounded-full">
<div className="text-black">
<div className="text-black font-bold text-xl mb-2 mt-8"><code className="!text-black">class</code> SandboxConnector</div>

</div>
</RandomGradientBackground>
```python
from mcp_use.connectors.sandbox import SandboxConnector
```

<Card type="info">
### `method` __init__

Initialize a new sandbox connector.


**Parameters**
><ParamField body="command" type="str" required="True" >   String value </ParamField>
><ParamField body="args" type="list[str]" required="True" >   List of items </ParamField>
><ParamField body="env" type="dict[str, str] | None" default="None" >   Environment variables for the user's MCP server command. </ParamField>
><ParamField body="e2b_options" type="mcp_use.client.connectors.sandbox.SandboxOptions | None" default="None" >   Configuration options for the E2B sandbox environment. </ParamField>
><ParamField body="timeout" type="float" default="5" >   Timeout for the sandbox process in seconds. </ParamField>
><ParamField body="sse_read_timeout" type="float" default="300" >   Timeout for the SSE connection in seconds. </ParamField>
><ParamField body="sampling_callback" type="mcp.client.session.SamplingFnT | None" default="None" >   Optional sampling callback. </ParamField>
><ParamField body="elicitation_callback" type="mcp.client.session.ElicitationFnT | None" default="None" >   Optional elicitation callback. </ParamField>
><ParamField body="message_handler" type="mcp.client.session.MessageHandlerFnT | None" default="None" >   Parameter value </ParamField>
><ParamField body="logging_callback" type="mcp.client.session.LoggingFnT | None" default="None" >   Callback function </ParamField>
><ParamField body="middleware" type="list[mcp_use.client.middleware.middleware.Middleware] | None" default="None" >   Middleware instance </ParamField>

**Signature**
```python wrap
def __init__(command: str, args: list[str], env: dict[str, str] | None = None, e2b_options: mcp_use.client.connectors.sandbox.SandboxOptions | None = None, timeout: float = 5, sse_read_timeout: float = 300, sampling_callback: mcp.client.session.SamplingFnT | None = None, elicitation_callback: mcp.client.session.ElicitationFnT | None = None, message_handler: mcp.client.session.MessageHandlerFnT | None = None, logging_callback: mcp.client.session.LoggingFnT | None = None, middleware: list[mcp_use.client.middleware.middleware.Middleware] | None = None):
```

</Card>
</div>
